\section{Introduction}
\label{subsec:intro}

Many programmers often make mistakes in developing softwares. Some of the errors
are easy to discover but others are hard to find. This is often due to dynamic
properties of the program and the multi-threading environment of the software.
In this paper, we dynamically discover and resolve two common hard-to-find
issues (deadlock and infinite loop) that many programmers often unknowingly
make.
We used a variant of AspectJ, Aspect Benchmark
Compiler~\cite{Avgustinov:2005:AEA:1052898.1052906} and one of its extension,
RacerAJ to help us detect resources locking and analyse the call graph in our approach.

Deadlock is often caused by different threads trying to hold the same resources
which have been held by the other threads, having bijection feature. It is
not possible to detect deadlock using static analysis as the resources that are
being held by the threads may be dynamically assigned. In this paper, we used two
special pointcuts, lock() and unlock() to help us determine which resources are being held by the
threads. We then used a deadlock algorithm\cite{Silberschatz:1999:OSC:554032},
which is commonly found in the context of Operating System, in detecting the deadlock. When a deadlock is
discovered, the system will inform the user about it and then let him decide on
the next action. We evaluate our approach by creating a deadlock application and the system is able to accurately display
the deadlock message and its information to the user.

Most of the time, if the application does not respond and stuck in the
same state, it is difficult for the programmers to determine straightaway
that it might be a deadlock. The stucked state may be an infinite loop
caused by the program. Within a loop, there is always a possibilty that an
infinite loop may occur.
A loop is defined as a set of instruction within a block that can be executed
more than once. Infinite loop therefore is the set of repeated execution of the
loop where there is no exit out of the block. Infinite loop waste many resources
and time, and can be hard to locate due to the dynamic nature of the program. In
this paper we locate a loop that most likely fall into the infinite loop
category using a variant of AspectJ, Aspect Benchmark Compiler, and inform the
user of this suspicion and allow him/her to break out the infinite loop.
We analyse the method calls made by the program using call graph analysis. If
a method call is detected to call a threshold number of times, then it will be
suspected as a infinite loop. We evaluate our approach by creating an infinite
program and the system is able to accurately display the infinite loop.

The remainder of this paper is organized as follows. After surveying the related
work in Section~\ref{subsec:relate}, we present our approach in Section
~\ref{subsec:approach} and evaluate it in
Section~\ref{subsec:evaluate}.
In Section~\ref{subsec:threat}, we discuss the limitations of our approach and
conclude with directions for future research in Section~\ref{subsec:conclude}.

